This invention relates to the automatic control of welding, cutting and related applications utilizing a laser beam tool to perform operations on a workpiece. Specifically the invention relates to apparatus and methods for determining and controlling the position and orientation of a tool head relative to a workpiece for carrying out programmed instructions for manufacturing operations. More specifically it relates to measuring and controlling the distance between the tool and the workpiece as the machine operates, determining the location of the focal point of the laser beam and optimally aligning it relative to the surface of the workpiece and for calculating the orientation of a tool control axis normal to a complex surface of a workpiece. The system also includes provision for recognizing the programs to be run for a sequence of operations by recognizing the tooling of the workpiece to identify the part program of operations related to the particular workpiece.